package com.ruoyi.cinema.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.cinema.BO.CanUsePriceBO;
import com.ruoyi.cinema.BO.GetEffectivePromoBO;
import com.ruoyi.cinema.BO.PayTypeBo;
import com.ruoyi.cinema.DTO.*;
import com.ruoyi.cinema.domain.*;
import com.ruoyi.cinema.mapper.ComboGroupGoodsMapper;
import com.ruoyi.cinema.mapper.GoodsCategoryMapper;
import com.ruoyi.cinema.mapper.GoodsMapper;
import com.ruoyi.cinema.service.IGoodsService;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.constant.OrderConstant;
import com.ruoyi.order.domain.OrderGoods;
import com.ruoyi.order.domain.OrderGoodsCombo;
import com.ruoyi.order.domain.OrderPromotion;
import com.ruoyi.utils.YzResult;
import com.ruoyi.utils.YzUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 卖品Service业务层处理
 *
 * @author HHAOYU
 * @date 2020-12-09
 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements IGoodsService  {
    @Autowired
    private GoodsMapper goodsMapper;
    @Autowired
    private ComboGroupGoodsMapper comboGroupGoodsMapper;
    @Autowired
    private GoodsCategoryMapper goodsCategoryMapper;

    /**
     * 查询卖品
     *
     * @param id 卖品ID
     * @return 卖品
     */
    @Override
    public Goods selectGoodsById(Long id)
    {
        return goodsMapper.selectGoodsById(id);
    }

    /**
     * 查询卖品列表
     *
     * @param goods 卖品
     * @return 卖品
     */
    @Override
    public List<Goods> selectGoodsList(Goods goods)
    {
        return goodsMapper.selectGoodsList(goods);
    }
    @Override
    public List<Goods> selectGoodsListForApi(Goods goods, String cinemaLinkId, String accessToken){
       List<Goods> goodsList =  goodsMapper.selectGoodsListForApi(goods);
       if(null != goodsList){
           ArrayList<GoodsYzDTO> goodsYzDTOArrayList = new ArrayList<>(goodsList.size());
           goodsList.forEach((g)->{
               GoodsYzDTO goodsYzDTO = new GoodsYzDTO();
               goodsYzDTO.setGoodsCode(g.getGoodsCode());
               goodsYzDTOArrayList.add(goodsYzDTO);
           });
          YzResult<GoodsPromoRetYzDTO> goodsPromoList =  YzUtils.getGoodsPromoList(cinemaLinkId,goodsYzDTOArrayList,accessToken);
          if(goodsPromoList.getResultCode().equals(Constants.YZSUCCESS) && goodsPromoList.getData().getBizCode().equals(Constants.BIZSUCCESS)){
              GoodsPromoRetYzDTO goodsPromoRetYzDTO = goodsPromoList.getData().getBizData();
              List<GoodsPromoYzDTO> goodsPromoYzDTOList = goodsPromoRetYzDTO.getGoodsPromoList();
              if(null != goodsPromoYzDTOList){
                  //获取最便宜的优惠
                  for (GoodsPromoYzDTO goodsPromoYzDTO :goodsPromoYzDTOList) {
                      for (Goods g :goodsList) {
                          if(g.getGoodsCode().equals(goodsPromoYzDTO.getGoodsCode())){
                              if(null == g.getActivityPrice() || g.getActivityPrice() > goodsPromoYzDTO.getPromoPrice()){
                                  g.setActivityPrice(goodsPromoYzDTO.getPromoPrice());
                                  break;
                              }

                          }
                      }
                  }
              }

          }
       }
       return goodsList;
    }

    @Override
    public List<Goods> selectGoodsListForAdmin(Goods goods){
        return goodsMapper.selectGoodsListForAdmin(goods);
    }

    /**
     * 新增卖品
     *
     * @param goods 卖品
     * @return 结果
     */
    @Override
    public int insertGoods(Goods goods)
    {
        return goodsMapper.insertGoods(goods);
    }

    /**
     * 修改卖品
     *
     * @param goods 卖品
     * @return 结果
     */
    @Override
    public int updateGoods(Goods goods)
    {
        return goodsMapper.updateGoods(goods);
    }

    /**
     * 批量删除卖品
     *
     * @param ids 需要删除的卖品ID
     * @return 结果
     */
    @Override
    public int deleteGoodsByIds(Long[] ids)
    {
        return goodsMapper.deleteGoodsByIds(ids);
    }

    /**
     * 删除卖品信息
     *
     * @param id 卖品ID
     * @return 结果
     */
    @Override
    public int deleteGoodsById(Long id)
    {
        return goodsMapper.deleteGoodsById(id);
    }


    @Override
    public List<CanUsePriceBO> getCanUsePrice(GetEffectivePromoBO gepb){

        List<CanUsePriceBO> canUsePriceBOList = new ArrayList<>();
        CanUsePriceBO original = new CanUsePriceBO();
        List<OrderGoods> orderGoodsList = new ArrayList<>(gepb.getGoodsList().size());
        Long originalOrderAmount = 0L;
        for (EffectivePromoGoodsYzDTO effectiveGoodsPromoYzDTO :gepb.getGoodsList()) {

            //todo 后面不应该两次查询
            Goods goods = goodsMapper.selectGoodsById(effectiveGoodsPromoYzDTO.getId());
            GoodsCategory goodsCategory = goodsCategoryMapper.selectGoodsCategoryById(goods.getCategoryId());
            originalOrderAmount += goods.getGoodsSettlePrice();
            OrderGoods orderGoods = new OrderGoods();
            orderGoods.setGoodsCode(effectiveGoodsPromoYzDTO.getGoodsCode());
            orderGoods.setGoodsCount(effectiveGoodsPromoYzDTO.getGoodsCount());
            orderGoods.setCategoryCode(goodsCategory.getCategoryCode());
            orderGoods.setComboList(effectiveGoodsPromoYzDTO.getComboList());

            if(null != orderGoods.getComboList() && !orderGoods.getComboList().isEmpty()){
                for (OrderGoodsCombo ogc :orderGoods.getComboList()) {
                    ComboGroupGoods comboGroupGoods = comboGroupGoodsMapper.selectComboGroupGoodsById(ogc.getId());
                    ogc.setGoodsName(comboGroupGoods.getGoodsName());
                    ogc.setGoodsCode(comboGroupGoods.getGoodsCode());
                    ogc.setGoodsType(comboGroupGoods.getGoodsType());
                    ogc.setId(null);
                    ogc.setExtraMoney(comboGroupGoods.getExtraMoney());
                    if(null != comboGroupGoods.getExtraMoney()){
                        originalOrderAmount +=ogc.getExtraMoney();
                    }
                }
            }
            orderGoods.setGoods(goods);
            orderGoodsList.add(orderGoods);
        }
        original.setOrderAmount(originalOrderAmount);
        original.setPayAmount(original.getOrderAmount());
        original.setPromoAmount(0L);
        original.setCanUse(true);
        original.setPromoTag("无优惠");
        original.setGoodsPayAmount(original.getPayAmount());
      //  original.setOrderGoodsList(orderGoodsList);//查询卖品订单清单
        YzResult<CardInfoYzDTO> cardInfoYzDTOResult = YzUtils.getCardList(gepb.getAccessToken());

        Map<String,CardInfoYzDTO> cardInfoYzDTOMap = null;
        if(cardInfoYzDTOResult.getResultCode().equals(Constants.YZSUCCESS) && cardInfoYzDTOResult.getData().getBizCode().equals(Constants.BIZSUCCESS)){
            List<CardInfoYzDTO> cardInfoYzDTOList =  cardInfoYzDTOResult.getData().getBizDataList();
            if(null != cardInfoYzDTOList && !cardInfoYzDTOList.isEmpty()){
                cardInfoYzDTOMap = cardInfoYzDTOList.stream().collect(Collectors.toMap(CardInfoYzDTO::getCardNo, cardInfoYzDTO -> cardInfoYzDTO));
            }
        }
        YzResult<EffectivePromoAllYzDTO> effectivePromoAllYzDTOResult =  YzUtils.getEffectivePromoList(gepb);
        if(effectivePromoAllYzDTOResult.getResultCode().equals(Constants.YZSUCCESS) && effectivePromoAllYzDTOResult.getData().getBizCode().equals(Constants.BIZSUCCESS)) {
            EffectivePromoAllYzDTO efpayd = effectivePromoAllYzDTOResult.getData().getBizData();
            if(null != efpayd && null != efpayd.getPromoList()) {
                List<EffectivePromoYzDTO> effectivePromoYzDTOList = efpayd.getPromoList();
                for (EffectivePromoYzDTO epy : effectivePromoYzDTOList) {
                    List<EffectiveGoodsPromoYzDTO> egpydl = epy.getGoodsPromoList();
                    Long promoPayAmount = 0L;
                    for (EffectiveGoodsPromoYzDTO egpyd :egpydl) {
                        promoPayAmount += egpyd.getOriginalGoodsPrice();
                    }
                    epy.setPromoPrice(original.getOrderAmount() - promoPayAmount + epy.getPromoPrice());
                    CanUsePriceBO canUsePriceBO = new CanUsePriceBO();
                    /** 若有卡优惠可用 */
                    if (null != epy.getCardList() && !epy.getCardList().isEmpty()) {
                        EffectiveCardYzDTO ecyd = epy.getCardList().get(0);
                        if(null == ecyd.getCardType()){
                            CardInfoYzDTO cardInfoYzDTO = cardInfoYzDTOMap.get(ecyd.getCardNo());
                            ecyd.setCardType(cardInfoYzDTO.getCardType());
                            ecyd.setCardRuleName(cardInfoYzDTO.getCardRuleName());
                        }
                        /** 若为储值卡*/
                        if (ecyd.getCardType().equals("DEPOSIT")) {
                            canUsePriceBO.setPromoTag(ecyd.getCardRuleName()+":"+ecyd.getCardNo());
                            if (null == epy.getPromoActivityList() || epy.getPromoActivityList().isEmpty()) {
                                canUsePriceBO.setOrderAmount(original.getOrderAmount());
                                canUsePriceBO.setPayAmount(epy.getPromoPrice());
                                canUsePriceBO.setPromoAmount(canUsePriceBO.getOrderAmount() - canUsePriceBO.getPayAmount());
                                OrderPromotion orderPromotion = new OrderPromotion();
                                orderPromotion.setPromoType(OrderConstant.PROMO_TYPE_MEMBER);
                                orderPromotion.setPromoCode(ecyd.getCardNo());
                                orderPromotion.setPromoAmount(canUsePriceBO.getPromoAmount());
                                List<OrderPromotion> orderPromotionList = new ArrayList<>(1);
                                orderPromotionList.add(orderPromotion);
                               // canUsePriceBO.setPromotionList(orderPromotionList);//查询促销产品订单

                            } else {

                                canUsePriceBO.setOrderAmount(original.getOrderAmount());
                                canUsePriceBO.setPayAmount(epy.getPromoPrice());
                                canUsePriceBO.setPromoAmount(canUsePriceBO.getOrderAmount() - canUsePriceBO.getPayAmount());
                                OrderPromotion orderPromotion = new OrderPromotion();
                                orderPromotion.setPromoType(OrderConstant.PROMO_TYPE_ACTIVITY);
                                orderPromotion.setPromoCode(epy.getPromoActivityList().get(0).getActivityCode());
                                orderPromotion.setPromoAmount(canUsePriceBO.getPromoAmount());
                                List<OrderPromotion> orderPromotionList = new ArrayList<>(1);
                                orderPromotionList.add(orderPromotion);
                                canUsePriceBO.setPromotionList(orderPromotionList);
                                canUsePriceBO.setPromoTag(ecyd.getCardRuleName()+ ":"+ecyd.getCardNo()+"专享-"+epy.getPromoActivityList().get(0).getActivityTag());
                            }
                            if (null != cardInfoYzDTOMap) {
                                CardInfoYzDTO cardInfoYzDTO = cardInfoYzDTOMap.get(ecyd.getCardNo());
                                if (cardInfoYzDTO.getCardAmount() < canUsePriceBO.getPayAmount()) {
                                    canUsePriceBO.setCanUse(false);
                                    canUsePriceBO.setPayType(CanUsePriceBO.MEMBER_CARD_PAY);
                                    canUsePriceBO.setCanNotUseReason("余额不足");
                                } else {
                                    canUsePriceBO.setCanUse(true);
                                    canUsePriceBO.setPayType(CanUsePriceBO.MEMBER_CARD_PAY);
                                }
                                List<OrderGoods> otbList = new ArrayList<>(original.getOrderGoodsList().size());
                                for (OrderGoods og : original.getOrderGoodsList()) {
                                    OrderGoods orderGoods = new OrderGoods();
                                    BeanUtil.copyProperties(og,orderGoods);
                                    if (null != epy.getPromoActivityList() && !epy.getPromoActivityList().isEmpty()) {
                                        EffectiveGoodsPromoYzDTO chooseObj = null;
                                        for (EffectiveGoodsPromoYzDTO egp :epy.getGoodsPromoList()) {
                                            if(og.getGoodsCode().equals(egp.getGoodsCode())){
                                                chooseObj = egp;
                                                orderGoods.setActivityCode(egp.getPromoCode());
                                            }
                                        }
                                        if(null != chooseObj){
                                            epy.getGoodsPromoList().remove(chooseObj);
                                        }
                                    }
                                    otbList.add(orderGoods);
                                }
                                canUsePriceBO.setOrderGoodsList(otbList);

                            }
                            List<PayTypeBo> payTypeBoList = new ArrayList<>(1);
                            PayTypeBo payTypeBo = new PayTypeBo();
                            payTypeBo.setPayType(PayTypeBo.MEMBER_CARD_PAY);
                            payTypeBo.setCardNo(ecyd.getCardNo());
                            payTypeBo.setCardRuleName(ecyd.getCardRuleName());
                            payTypeBo.setPayAmount(canUsePriceBO.getPayAmount());
                            payTypeBo.setPayCode(ecyd.getCardNo());
                            payTypeBo.setPayMethodCode(OrderConstant.MEMBER_CARD);
                            payTypeBoList.add(payTypeBo);
                            canUsePriceBO.setPayTypeList(payTypeBoList);

                        }else {
                            /** 若为权益卡*/
                            //todo 现在只支持储值卡和权益卡 此种情况都认为为权益卡

                            canUsePriceBO.setOrderAmount(original.getOrderAmount());
                            canUsePriceBO.setCanUse(true);
                            canUsePriceBO.setPayType(CanUsePriceBO.WEIXIN_PAY);
                            canUsePriceBO.setPayAmount(epy.getPromoPrice());
                            canUsePriceBO.setPromoAmount(canUsePriceBO.getOrderAmount() - canUsePriceBO.getPayAmount());

                            List<OrderGoods> otbList = new ArrayList<>(original.getOrderGoodsList().size());
                            for (OrderGoods og : original.getOrderGoodsList()) {
                                OrderGoods orderGoods = new OrderGoods();
                                BeanUtil.copyProperties(og,orderGoods);
                                if (null != epy.getPromoActivityList() && !epy.getPromoActivityList().isEmpty()) {
                                    EffectiveGoodsPromoYzDTO chooseObj = null;
                                    for (EffectiveGoodsPromoYzDTO egp :epy.getGoodsPromoList()) {
                                        if(og.getGoodsCode().equals(egp.getGoodsCode())){
                                            chooseObj = egp;
                                            orderGoods.setActivityCode(egp.getPromoCode());
                                        }
                                    }
                                    if(null != chooseObj){
                                        epy.getGoodsPromoList().remove(chooseObj);
                                    }
                                }
                                otbList.add(orderGoods);
                            }
                            canUsePriceBO.setOrderGoodsList(otbList);

                            if (null != epy.getPromoActivityList() && !epy.getPromoActivityList().isEmpty()) {
                                OrderPromotion orderPromotion = new OrderPromotion();
                                orderPromotion.setPromoType(OrderConstant.PROMO_TYPE_ACTIVITY);
                                orderPromotion.setPromoCode(epy.getPromoActivityList().get(0).getActivityCode());
                                orderPromotion.setPromoAmount(canUsePriceBO.getPromoAmount());
                                OrderPromotion opMember = new OrderPromotion();
                                opMember.setPromoType(OrderConstant.PROMO_TYPE_PRIVILEGE);
                                opMember.setPromoCode(ecyd.getCardNo());
                                opMember.setPromoAmount(0L);
                                List<OrderPromotion> orderPromotionList = new ArrayList<>(2);
                                orderPromotionList.add(orderPromotion);
                                orderPromotionList.add(opMember);
                                canUsePriceBO.setPromotionList(orderPromotionList);
                                canUsePriceBO.setPromoTag(ecyd.getCardRuleName()+ ":"+ecyd.getCardNo()+"专享-"+epy.getPromoActivityList().get(0).getActivityTag());
                            }else {
                                OrderPromotion orderPromotion = new OrderPromotion();
                                orderPromotion.setPromoType(OrderConstant.PROMO_TYPE_MEMBER);
                                orderPromotion.setPromoCode(ecyd.getCardNo());
                                orderPromotion.setPromoAmount(canUsePriceBO.getPromoAmount());
                                List<OrderPromotion> orderPromotionList = new ArrayList<>(1);
                                orderPromotionList.add(orderPromotion);
                                canUsePriceBO.setPromotionList(orderPromotionList);
                                canUsePriceBO.setPromoTag(ecyd.getCardRuleName()+ ":"+ecyd.getCardNo());
                            }
                            List<PayTypeBo> payTypeBoList = new ArrayList<>();
                            PayTypeBo payTypeBo = new PayTypeBo();
                            payTypeBo.setPayType(PayTypeBo.WEIXIN_PAY);
                            payTypeBo.setPayAmount(canUsePriceBO.getPayAmount());
                            payTypeBo.setPayCode(IdUtils.fastSimpleUUID());
                            payTypeBo.setPayMethodCode(OrderConstant.WEIXIN);
                            payTypeBoList.add(payTypeBo);
                            canUsePriceBO.setPayTypeList(payTypeBoList);


                        }
                    }else{
                        /** 若没有卡优惠可用 这时可用卡支付也可用微信支付 此时 如卡余额足够，则可选择卡支付*/

                        canUsePriceBO.setOrderAmount(original.getOrderAmount());
                        canUsePriceBO.setCanUse(true);
                        canUsePriceBO.setPayType(CanUsePriceBO.BOOTH);
                        canUsePriceBO.setPayAmount(epy.getPromoPrice());
                        canUsePriceBO.setPromoAmount(canUsePriceBO.getOrderAmount() - canUsePriceBO.getPayAmount());
                        if (null != epy.getPromoActivityList() && !epy.getPromoActivityList().isEmpty()) {
                            OrderPromotion orderPromotion = new OrderPromotion();
                            orderPromotion.setPromoType(OrderConstant.PROMO_TYPE_ACTIVITY);
                            orderPromotion.setPromoCode(epy.getPromoActivityList().get(0).getActivityCode());
                            orderPromotion.setPromoAmount(canUsePriceBO.getPromoAmount());
                            List<OrderPromotion> orderPromotionList = new ArrayList<>(1);
                            orderPromotionList.add(orderPromotion);
                            canUsePriceBO.setPromotionList(orderPromotionList);
                            canUsePriceBO.setPromoTag(epy.getPromoActivityList().get(0).getActivityTag());
                        }


                        List<OrderGoods> otbList = new ArrayList<>(original.getOrderGoodsList().size());
                        for (OrderGoods og : original.getOrderGoodsList()) {
                            OrderGoods orderGoods = new OrderGoods();
                            BeanUtil.copyProperties(og,orderGoods);
                            if (null != epy.getPromoActivityList() && !epy.getPromoActivityList().isEmpty()) {
                                EffectiveGoodsPromoYzDTO chooseObj = null;
                                for (EffectiveGoodsPromoYzDTO egp :epy.getGoodsPromoList()) {
                                    if(og.getGoodsCode().equals(egp.getGoodsCode())){
                                        chooseObj = egp;
                                        orderGoods.setActivityCode(egp.getPromoCode());
                                    }
                                }
                                if(null != chooseObj){
                                    epy.getGoodsPromoList().remove(chooseObj);
                                }
                            }
                            otbList.add(orderGoods);
                        }
                        canUsePriceBO.setOrderGoodsList(otbList);

                    }
                    if(null !=canUsePriceBO.getPayAmount() && null != canUsePriceBO.getPromoTag()){
                        canUsePriceBOList.add(canUsePriceBO);
                    }
                }
            }

            if(null != efpayd && null != efpayd.getCouponPromo() && null != efpayd.getCouponPromo().getCouponList()){
                List<EffectiveCouponYzDTO> allCoupon = efpayd.getCouponPromo().getCouponList();
                if(!allCoupon.isEmpty()){
                    for (EffectiveCouponYzDTO ecyd :allCoupon) {
                        if(ecyd.getCanUse().equals("Y")){
                            CanUsePriceBO canUsePriceBO = new CanUsePriceBO();
                            canUsePriceBO.setCanUse(true);
                            canUsePriceBO.setOrderAmount(original.getOrderAmount());
                            canUsePriceBO.setPayAmount(canUsePriceBO.getOrderAmount());
                            canUsePriceBO.setPromoAmount(0L);
                            canUsePriceBO.setPayType(CanUsePriceBO.WEIXIN_PAY);
                            canUsePriceBO.setPromoTag(ecyd.getCouponName()+":"+ecyd.getCouponCode() +"减免金额"+(ecyd.getCouponPromoPrice()/100));
                            PayTypeBo couponPay = new PayTypeBo();
                            couponPay.setPayAmount(ecyd.getCouponPromoPrice());
                            couponPay.setPayMethodCode(OrderConstant.COUPON);
                            couponPay.setPayMethodId(IdUtils.fastSimpleUUID());
                            couponPay.setPayMethodName("优惠券");
                            couponPay.setPayCode(ecyd.getCouponCode());
                            couponPay.setPayApply("GOODS");
                            canUsePriceBO.setCouponPay(couponPay);
                            canUsePriceBO.setOrderGoodsList(orderGoodsList);
                            //todo 先测试礼券的微信补差
                            List<PayTypeBo> ptbl = new ArrayList<>();
                            PayTypeBo payTypeBo = new PayTypeBo();
                            payTypeBo.setPayType(PayTypeBo.WEIXIN_PAY);
                            payTypeBo.setPayAmount(canUsePriceBO.getPayAmount()-couponPay.getPayAmount());
                            payTypeBo.setPayCode(IdUtils.fastSimpleUUID());
                            payTypeBo.setPayMethodCode(OrderConstant.WEIXIN);
                            ptbl.add(payTypeBo);
                            canUsePriceBO.setPayTypeList(ptbl);
                            canUsePriceBOList.add(canUsePriceBO);
                        }
                    }
                }

            }

        }
        /** 加入原始价格*/
        canUsePriceBOList.add(original);
        for (CanUsePriceBO cpb :canUsePriceBOList) {
            if(null == cpb.getPayTypeList() || cpb.getPayTypeList().isEmpty()){
                List<PayTypeBo> payTypeBoList = new ArrayList<>();
                PayTypeBo payTypeBo = new PayTypeBo();
                payTypeBo.setPayType(PayTypeBo.WEIXIN_PAY);
                payTypeBo.setPayAmount(cpb.getPayAmount());
                payTypeBo.setPayCode(IdUtils.fastSimpleUUID());
                payTypeBo.setPayMethodCode(OrderConstant.WEIXIN);
                payTypeBoList.add(payTypeBo);
                if(null != cardInfoYzDTOMap){
                    for (CardInfoYzDTO cardInfoYzDTO : cardInfoYzDTOMap.values()) {
                        if(cardInfoYzDTO.getCardType().equals("DEPOSIT")){
                            if(cardInfoYzDTO.getCardAmount() > cpb.getPayAmount()){
                                PayTypeBo ptb = new PayTypeBo();
                                ptb.setPayType(PayTypeBo.MEMBER_CARD_PAY);
                                ptb.setCardNo(cardInfoYzDTO.getCardNo());
                                ptb.setCardRuleName(cardInfoYzDTO.getCardRuleName());
                                ptb.setPayAmount(cpb.getPayAmount());
                                ptb.setPayCode(cardInfoYzDTO.getCardNo());
                                ptb.setPayMethodCode(OrderConstant.MEMBER_CARD);
                                payTypeBoList.add(ptb);
                            }
                        }

                    }
                }
                cpb.setPayTypeList(payTypeBoList);
            }
        }
        canUsePriceBOList.sort((Comparator.comparing(CanUsePriceBO::getPayAmount)));
        return canUsePriceBOList;
    }






}
